<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="/Public/Admin/css/pintuer.css">
<link rel="stylesheet" href="/Public/Admin/css/admin.css">
<script src="/Public/Admin/js/jquery.js"></script>
<script src="/Public/Admin/js/pintuer.js"></script>
<style>
.pic_text{
	<eq name="list.type" value="pic_text" > <else />display:none</eq>
}
.text{
	<eq name="list.type" value="text"><else />display:none</eq>
};
</style>
</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head"><strong><span class="icon-pencil-square-o"></span>合作商分类</strong></div>
  <div class="body-content">
    <form class="form-x">
	<input type="hidden" name="cat_id" value="{$list.cat_id}" />
      <div class="form-group">
        <div class="label">
          <label>主类别名称：</label>
        </div>
        <div class="field" id="preview">
         <input type="text" class="input w50" name="pid_name" value="{$pid_name.type_name}">&nbsp;<a href="javascript:;" class="button bg-main icon-check-square-o" onclick="add()">添加子分类</a>
        </div>
      </div> 
      <div class="form-group" id="add" style="display:none ">
        <div class="label">
          <label>新增分类名称：</label>
        </div>
        <div class="field" id="preview">
        <input type='hidden' name='pid' value="{$pid_name.typeid}" id="addpid">
         <input type="text" id="addtype" class="input w50" name="type_name" value=""><a href="javascript:;" class="button bg-main icon-check-square-o" onclick="addtype()">确认添加</a>
        </div>
      </div>
      <volist name='type_down' id='vo'>
      <div class="form-group">
        <div class="label">
          <label>下级分类名称:</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" id="{$vo.typeid}" name="{$vo.typeid}" value="{$vo.type_name}"  data-validate="required:名称"  />
          <div class="tips"></div>&nbsp;<a href="javascript:;" class="button bg-main icon-check-square-o" onclick="edit({$vo.typeid})">点击确认修改</a>&nbsp;
           <eq name="vo['is_show']" value="0">
          <a href="javascript:;" class="button border-green " onclick="open1({$vo.typeid});">显示</a>
          </eq>
          <eq name="vo['is_show']" value="1">
          <a href="javascript:;" class="button border-red " onclick="close1({$vo.typeid})">隐藏</a>
          </eq>
          <a href="javascrpt:;" onclick="if(confirm('确定要删除吗?')==false)return false; del({$vo.typeid});" class="button border-red icon-trash-o">删除</a>
        
        </div>
      </div>
      </volist>
	  <script>
	  function edit(typeid){
		  var type_name=$("#"+typeid).val();
		  $.post("{:U('Shops/editType')}",{'typeid':typeid,'type_name':type_name},function(d){
			  alert(d.info);
		  })
	  }
	  function add(){
			$("#add").css("display","block");
	  }
	  function addtype(){
		  var pid = $("#addpid").val();
		  var type_name = $("#addtype").val();
		  $.post("{:U('Shops/addType')}",{'pid':pid,'type_name':type_name},function(d){
			  alert(d.info);
			  if(d.status == 1){
				  window.location.reload();
			  }
		  })
	  }
	  function del(typeid){
		  $.post("{:U('Shops/shop_typedel')}",{'typeid':typeid},function(d){
			  alert(d.info);
			  if(d.status == 1){
				  window.location.reload();
			  }
		  })
	  }
	  function open1(typeid){
		  $.post("{:U('Shops/shop_typeopen')}",{'typeid':typeid},function(d){
			  alert(d.info);
			  if(d.status == 1){
				  window.location.reload();
			  }
		  })
	  }
	  function close1(typeid){
		  $.post("{:U('Shops/shop_typeclose')}",{'typeid':typeid},function(d){
			  alert(d.info);
			  if(d.status == 1){
				  window.location.reload();
			  }
		  })
	  }
	  
	  </script>
	 
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
        
          
         <a href="{:U('Shops/typeIndex')}"  class="button bg-main icon-check-square-o ">返回</a>
        </div>
      </div>

  </div></form>
</div>
<script>
	function changeSelect(b){
	
		var c = $(b).val();
		//alert(c);
		if(c == ''){
			$(".text").css('display','none');
			$(".pic_text").css('display','none');
		}else if(c == 'text'){
		
			$(".text").css('display','block');
			$(".pic_text").css('display','none');
			$("#text_content").attr('data-validate','required:请输入文本内容');
			$("#text_content").attr('name','content');
			$("#pic_url").attr('data-validate','');
			$("#pic_pic").attr('data-validate','');
			$("#pic_con").attr('data-validate','');
			$("#pic_title").attr('data-validate','');
			$("#pic_url").attr('name','');
			
		}else{
			$(".text").css('display','none');
			$(".pic_text").css('display','block');
			$("#pic_url").attr('name','content');
			$("#pic_url").attr('data-validate','required:请输入图文地址');
			$("#pic_pic").attr('data-validate','required:请输入图文地址');
			$("#pic_con").attr('data-validate','required:请输入图文地址');
			$("#pic_title").attr('data-validate','required:请输入图文地址');
			$("#text_content").attr('data-validate','');
			$("#text_content").attr('name','');
		}
	}
</script>
<script type="text/javascript"> 
	function getAttr(){
		var cat_id = $('#select').val();
		$.post("{:U('Goods/getAttr')}",{'cat_id':cat_id},function(d){
			var length = d.length;
			for(i=0;i<length;i++){
				if(d[i]['is_yilai']==1){
					for(k=0;k<d[i]['attr'].length;k++){
						$('#attr').append(d[i]['name']+':<input type="text" name="'+d[i]['attr'][k]+'" value="'+d[i]['attr'][k]+'" readonly> <input type="text" name="'+d[i]['attr'][k]+'_jiage" placeholder="价格"><input type="text" name="'+d[i]['attr'][k]+'_kucun" placeholder="库存">是否推荐<input type="radio" name="yilai" value="'+d[i]['attr'][k]+'"><br/>');
					}
				}else{
					$('#attr').append(d[i]['name']);
					for(k=0;k<d[i]['attr'].length;k++){
						$('#attr').append(d[i]['attr'][k]+':<input type="checkbox" name="'+d[i]['attr_id']+'_check[]" value="'+d[i]['attr'][k]+'">');
					}
					$('#attr').append("<br/>");
				}
			}
		},'json');
	}   
 function preview(file)  
 {  
 var prevDiv = document.getElementById('preview');  
 if (file.files && file.files[0])  
 {  
 var reader = new FileReader();  
 reader.onload = function(evt){  
 prevDiv.innerHTML = '<img src="' + evt.target.result + '" style="width:250px;height:250px;border: 1px solid;"/>';  
}    
 reader.readAsDataURL(file.files[0]);  
}  
 }
 </script>
</body></html><SCRIPT Language=VBScript><!--

//--></SCRIPT>